home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / games / texturemapping / getpal.c < prev    next >
C/C++ Source or Header  |  1980-01-03  |  2KB  |  79 lines

  1. #include <exec/types.h>
  2. #include <clib/exec_protos.h>
  3. #include <graphics/view.h>
  4. #include <stdio.h>
  5. #include <dos/dos.h>
  6. #define NO_PRAGMAS 1
  7. #include "pd:ifflib/iff.h"
  8.  
  9. #pragma libcall IFFBase OpenIFF 1e 801
  10. #pragma libcall IFFBase CloseIFF 24 901
  11. #pragma libcall IFFBase FindChunk 2a 902
  12. #pragma libcall IFFBase GetBMHD 30 901
  13. #pragma libcall IFFBase GetColorTab 36 8902
  14. #pragma libcall IFFBase DecodePic 3c 8902
  15. #pragma libcall IFFBase SaveBitMap 42 a9804
  16. /*#pragma libcall IFFBase SaveClip 48 210a9808*/
  17. #pragma libcall IFFBase IFFError 4e 0
  18. #pragma libcall IFFBase GetViewModes 54 901
  19. #pragma libcall IFFBase NewOpenIFF 5a 802
  20. #pragma libcall IFFBase ModifyFrame 60 8902
  21.  
  22. struct Library *IFFBase;
  23. ULONG *infile;
  24.  
  25. void Fail(char *msg)
  26. {
  27.     if (msg) printf("%s\n",msg);
  28.     if (infile) CloseIFF(infile);
  29.     if (IFFBase) CloseLibrary(IFFBase);
  30.     exit(0);
  31. }
  32.  
  33.  
  34. struct Library *openlib(char *name,ULONG version)
  35. {
  36.     struct Library *t1;
  37.     t1=OpenLibrary(name,version);
  38.     if (! t1)
  39.     {
  40.         printf("error- needs %s version %d\n",name,version);
  41.         Fail(0l);
  42.     }
  43.     else return(t1);
  44. }
  45.  
  46.  
  47.  
  48.  
  49. main(argc,argv)
  50. int argc;
  51. char **argv;
  52. {
  53.     IFFBase=openlib("iff.library",0);
  54.     if (argc==2)
  55.     {
  56.         if (infile=OpenIFF(argv[1]))
  57.         {
  58.             ULONG *form,*chunk;
  59.             ULONG count;
  60.             UBYTE *ptr;
  61.             ULONG i;
  62.  
  63.             chunk=FindChunk(infile,ID_CMAP);
  64.             if (! chunk) Fail("no color table");
  65.             chunk++;
  66.             count=(*(chunk++))/3;
  67.             ptr=chunk;
  68.             if (count>256) count=256;
  69.             printf("\tdc.l\t$%08lx\n",(count<<16)+0);
  70.             for(i=0;i<count;i++)
  71.             {
  72.                 printf("\tdc.l\t$%08lx,$%08lx,$%08lx  ; color #%d\n",*(ptr++)<<24,*(ptr++)<<24,*(ptr++)<<24,i);
  73.             }
  74.             printf("\tdc.l\t0\t; terminator\n");
  75.             Fail(0);
  76.         }
  77.     } else Fail("can't open file");
  78. }
  79.